package com.mingtu.jgspatrol.adapter;

import android.content.Context;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.StringUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mingtu.jgspatrol.R;
import com.mingtu.jgspatrol.bean.SuperJobListBean;

public class JobSupervisionAdapter extends BaseQuickAdapter<SuperJobListBean.PageBean.ListBean, BaseViewHolder> {
    private Context context;

    public JobSupervisionAdapter(Context context) {
        super(R.layout.item_job_supervision);
        this.context = context;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, SuperJobListBean.PageBean.ListBean listBean) {
        String jobName = listBean.getName();
        String createTime = listBean.getCreateTime();
        String finishTime = listBean.getFinishTime();
        String type = listBean.getType();

        if (!StringUtils.isEmpty(jobName)) {
            helper.setText(R.id.tv_title, jobName);
        }

        if (!StringUtils.isEmpty(createTime)) {
            helper.setText(R.id.tv_start_time, createTime);
        }

        if (!StringUtils.isEmpty(finishTime)) {
            helper.setText(R.id.tv_end_time, finishTime);
        }

        TextView tvType = helper.getView(R.id.tv_type);
        if (!StringUtils.isEmpty(type)) {
            tvType.setText(type);
        }

        if (type.indexOf("巡护") != -1) {
            tvType.setBackground(context.getDrawable(R.drawable.shape_bg_task_type1));
            tvType.setTextColor(context.getResources().getColor(R.color.main_color_3aa));
        } else if (type.indexOf("下发") != -1) {
            tvType.setBackground(context.getDrawable(R.drawable.shape_bg_task_type2));
            tvType.setTextColor(context.getResources().getColor(R.color.bg_color_519));
        } else if (type.indexOf("火情") != -1) {
            tvType.setBackground(context.getDrawable(R.drawable.shape_bg_task_type4));
            tvType.setTextColor(context.getResources().getColor(R.color.bg_color_dc6));
        }
    }


}
